package com.zhangjie.controller;

import com.zhangjie.cmn.client.DictFeignClient;
import com.zhangjie.common.result.Result;
import com.zhangjie.model.hosp.Hospital;
import com.zhangjie.service.HospitalService;
import com.zhangjie.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {
    @Autowired
    HospitalService hospitalService;
    @Autowired   //注入远程调用类
    private DictFeignClient dictFeignClient;

    //医院列表
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable("page") Integer page,
                           @PathVariable("limit") Integer limit,
                           HospitalQueryVo hospitalQueryVo){
        Page pageModel=hospitalService.selectHospPage(page,limit,hospitalQueryVo);
        return Result.ok(pageModel);
    }
//
//    //根据dictCode获取下级节点
//    @ApiOperation(value = "根据dictCode获取下级节点——远程调用")
//    @GetMapping("findByDictCode/{dictCode}")
//    public Result findByDictCode(@PathVariable String dictCode){
//        return  dictFeignClient.findByDictCode(dictCode);
//    }
//
//    @ApiOperation(value = "根据数据id查询子数据列表——远程调用")
//    @GetMapping("/findChildData/{id}")
//    public Result findChildData(@PathVariable Long id){
//        return dictFeignClient.findChildData(id);
//    }

    //更新医院上线状态
    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id,@PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    //医院详情信息
    @ApiOperation(value = "医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id){
        Map<String,Object> map=hospitalService.getHospById(id);
        return Result.ok(map);
    }




}
